<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ include file="/taglibs.jsp"%>
<c-rt:set var="ss" value='<%=System.currentTimeMillis()%>'/>
<c-rt:if test="${errMsg!=null}">
<h1>修改订单及运费</h1>
${errMsg }
<div class="f-link">
	<a href="javascript:history.back()">回上一页</a>
</div>
</c-rt:if>
<c-rt:if test="${errMsg==null}">
${pu:reqSet('user', pu:user())}
<%--判斷訂單修改 --%>
<c-rt:set var="canChgPaymentIfo" value="N"/>
<c-rt:set var="canChgRecvInfo" value="N"/>

<c:choose>
	<c:when test="${order.paymentTp=='30' || order.paymentTp=='60'}">
		<c:if test="${order.orderSt=='00'}">
			<c-rt:set var="canChgPaymentIfo" value="Y"/>
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
		<c:if test="${order.orderSt=='20' }">
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
	</c:when>
	<c:otherwise>
		<c:if test="${order.paymentSt=='00' && order.orderSt == '10'}">		
			<c-rt:set var="canChgPaymentIfo" value="Y"/>					
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
		<c:if test="${order.paymentSt=='10' && order.sync=='false' && order.orderSt == '20'}">
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>			          
	</c:otherwise> 
</c:choose>
<script type="text/javascript" charset="UTF-8" src="../js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="../js/jquery.alphanumeric.js"></script>
<link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.7.2.custom.css"/>
<style>
.type-0,.type-1,.type-2,.type-3,.type-4,.type-5,.type-money{font-size:12px; padding:1px 3px;*padding:3px 3px 0;}
.type-0{display:none;} /* 主商品 */
.type-1{background:#FCF; color:#333;}/* 預購 */
.type-2{background:#94ebf2; color:#333;}/* 贈品 */
.type-3{background:#ffcc99; color:#333;}/* 加購 */
.type-4{background:#d5f091; color:#333;}/* 活動 */
.type-5{ background:#FF0; color:#333; }/* 满额购 */
.type-6{background:#d5f091; color:#333;}/* 活動 */
</style>
<script language="javascript">
var content;
var shipfare=0;
var checkBonus=0;
var hasChecked=false;
var hasNoCheck=false;
var giftcardBalance=0;
var myWallet = 0;
<c-rt:if test="${order.paymentSt=='10'}">
myWallet=parseFloat("${order.myWallet+order.cash}").toFixed(1);
giftcardBalance=parseFloat("${order.giftcardBalance}").toFixed(1);
</c-rt:if>
<c-rt:if test="${order.paymentSt=='00'}">
myWallet=parseFloat("${order.myWallet}").toFixed(1);
giftcardBalance=parseFloat("${order.giftcardBalance}").toFixed(1);
</c-rt:if>
var myBonus=parseFloat("${order.bonus}").toFixed(1);
var myDiscount=parseFloat("${order.discount}").toFixed(1);
var myCoupon=parseFloat("${order.coupon}").toFixed(1);
var myTotalPrice=parseFloat("${order.totalPrice}").toFixed(1);
function refillForm(theTotalPrice, theDiscount, theCoupon, theCodFee){
	//TODO:totalPrice与amount
	$('#aDiscount').text(parseFloat(theDiscount).toFixed(1));
	$('#aCoupon').text(parseFloat(theCoupon).toFixed(1));
	var shipfare=parseFloat($('#newShipfare').attr('value')).toFixed(1);
	var theTotalOrderPrice=parseFloat(theTotalPrice-theDiscount-theCoupon-checkBonus+shipfare+theCodFee).toFixed(1);
	//alert(theTotalOrderPrice+','+theTotalPrice+","+theDiscount+","+theCoupon+","+checkBonus+","+shipfare+","+theCodFee);
	$('#aTotalPrice').text(parseFloat(theTotalPrice).toFixed(1));
	$('#aAmount').text(parseFloat(theTotalPrice - theDiscount).toFixed(1));
	$('#aTotalOrderPrice').text(parseFloat(theTotalOrderPrice).toFixed(1));

	//alert("giftcardBalance:::"+giftcardBalance);
	//alert("theTotalOrderPrice:::"+theTotalOrderPrice);
	//alert(parseFloat(giftcardBalance) > parseFloat(theTotalOrderPrice));
	//先用礼品卡余额支付
	if(parseFloat(giftcardBalance) > parseFloat(theTotalOrderPrice) && giftcardBalance!=0){
		$('#aGiftcardBalance').text(theTotalOrderPrice);
	}else{
		$('#aGiftcardBalance').text(giftcardBalance);
	}	
	var theGiftcardBalance=$('#aGiftcardBalance').text();	

	alert(parseFloat(myWallet) );
	alert(parseFloat(theTotalOrderPrice-giftcardBalance) );
	alert(parseFloat(myWallet) > parseFloat(theTotalOrderPrice-giftcardBalance));
	//再用账户余额支付
	if( parseFloat(myWallet) > parseFloat(theTotalOrderPrice-giftcardBalance) && myWallet!=0){
		$('#aMyWallet').text(parseFloat(theTotalOrderPrice-theGiftcardBalance).toFixed(1));
	}else{
		$('#aMyWallet').text(parseFloat(myWallet).toFixed(1));
	}
	var theMyWallet=$('#aMyWallet').text();

	//mustPay
	var theMustPay=theTotalOrderPrice-theMyWallet-theGiftcardBalance;
	$('#aMustPay').text(parseFloat(theMustPay).toFixed(1));

	if(parseFloat(myWallet+giftcardBalance-theTotalOrderPrice) > 0){
		$('#aMustReturn').text(parseFloat(myWallet+giftcardBalance-theTotalOrderPrice).toFixed(1));
	}else{
		$('#aMustReturn').text(0.0);
	}
/*
	alert("aDiscount:"+$('#aDiscount').text());
	alert("aCoupon:"+$('#aCoupon').text());
	alert("aTotalPrice:"+$('#aTotalPrice').text());
	alert("aAmount:"+$('#aAmount').text());
	alert("aTotalOrderPrice:"+$('#aTotalOrderPrice').text());
	alert("aGiftcardBalance:"+$('#aGiftcardBalance').text());
	alert("aMyWallet:"+$('#aMyWallet').text());
	alert("aMustPay:"+$('#aMustPay').text());
	alert("aMustReturn:"+$('#aMustReturn').text());
	*/
}
function getFreight(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum){
	//var theSumTotalPrice=theTotalPrice-theDiscount-theCoupon;
	//alert(theTotalPrice+","+theDiscount+","+theCoupon+","+checkBonus+","+shipfare+","+theCodFee+","+weightSum);
	//运费的计算方式(用商品总额-折扣金额计算)
	$.getJSON('/ecadmin/crmUpdateOrder/getFreight.do?ss=${ss}',{receiverProvince:"${pu:urlEncoding(order.receiverProvince,'UTF-8')}", weightSum:weightSum, orderPrice:theTotalPrice,orderDiscount:theDiscount},
			function(result){
		shipfare=parseFloat(result).toFixed(1);
		$('#newShipfare').attr('value', shipfare);
		//alert(shipfare);
		//refillForm(theTotalPrice, theDiscount, theCoupon, theCodFee);
		if(myBonus>0){
			getBonus(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum, shipfare);
		}else{
			refillForm(theTotalPrice, theDiscount, theCoupon, theCodFee);
		}
		return false;
	});
}
function getBonus(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum, theShipfare){
	//会员积分的计算方式(用订单总额-discount-coupon算)，取整数
	var theSumPrice=theTotalPrice-theDiscount-theCoupon;
	$.getJSON('/ecadmin/crmUpdateOrder/calBonus.do?ss=${ss}',{orderId:"${order.orderId}",totalPrice:theSumPrice},
			function(result){
		checkBonus=result;
		//alert(theSumPrice+';'+result);
		//购物金只允许原订单的上额
		if(checkBonus>myBonus)checkBonus=myBonus;
		$('#aBonus').text(parseFloat(result).toFixed(1));
		<c-rt:if test="${not empty order.orderBonusCampaign}">
			$("#aBonusDiscount").text(parseFloat($('#aBonus').text())*parseFloat("${order.orderBonusCampaign.offsetRate}"));
		</c-rt:if>
		<c-rt:if test="${empty order.orderBonusCampaign}">
			$("#aBonusDiscount").text("0");		
		</c-rt:if>
		
		//getFreight(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum);
		refillForm(theTotalPrice, theDiscount, theCoupon, theCodFee);
		return false;
	});
}
function calBonusAndShipfare(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum){
	//var theSumTotalPrice=theTotalPrice-theDiscount-theCoupon-checkBonus+theCodFee;
	//alert(theTotalPrice+","+theDiscount+","+theCoupon+","+checkBonus+","+shipfare+","+theCodFee);
	getFreight(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum);

}
	$().ready( function() {	
		$('#submitForm').click(function(){
			hasChecked=false;
			hasNoCheck=false;
			$('.cancelProduct').each(function(){
				if($(this).attr('checked')){
					hasChecked=true;
				}
				if(!$(this).attr('checked')){
					hasNoCheck=true;
				}
			});
			var errMsg='';
			if(!hasChecked){
				errMsg+='请勾取要取消的商品!\r\n';
			}else if(!hasNoCheck){
				errMsg+='不允许取消所有商品!\r\n';
			}

			if(errMsg!=''){
				alert(errMsg);
			}else{
				var msg='注意！点击确定后将会从订单中取消以下商品的订购（包含加购／赠品）\r\n';
				var productIds="";
				$('.cancelProduct').each(function(){
					cancelProduct=$(this).attr('value').split('_');
					
					if($(this).attr('checked')){
						if(productIds!=''){
							productIds+=',';
						}
						productIds+=cancelProduct[5];
						
					}
				});
				if(confirm(msg+productIds)){
					document.orderForm.submit();
				}
			}	
		});
		var aTotalPrice=myTotalPrice;
		var aDiscount=parseFloat($('#aDiscount').text()).toFixed(1);
		
		var aCoupon=parseFloat($('#aCoupon').text()).toFixed(1);
		var aBonus=parseFloat($('#aBonus').text()).toFixed(1);
		var newShipfare=parseFloat($('#newShipfare').attr('value')).toFixed(1);
		var aCodFee=parseFloat($('#aCodFee').text()).toFixed(1);
		
		var aMyWallet=parseFloat($('#aMyWallet').text()).toFixed(1);
		var aGiftcardBalance=parseFloat($('#aGiftcardBalance').text()).toFixed(1);
		var aMustPay=parseFloat($('#aMustPay').text()).toFixed(1);
		$('#newShipfare').change(function(){
			//var theTotalPrice=parseFloat($('#aTotalPrice').text());
			var aTotalOrderPrice=aTotalPrice-aDiscount-aCoupon-aBonus+newShipfare+aCodFee;
			var theDiscount=parseFloat($('#aDiscount').text()).toFixed(1);
			var theCoupon=parseFloat($('#aCoupon').text()).toFixed(1);
			var theCodFee=parseFloat($('#aCodFee').text()).toFixed(1);
			refillForm(theTotalPrice, theDiscount, theCoupon, theCodFee);
		});
		$('.cancelProduct').each(function(){
			$(this).attr('checked', false);
			$(this).click(function(){
				var weightSum=0;
				
				var theTotalPrice=aTotalPrice;
				var theDiscount=myDiscount;
				var theCoupon=myCoupon;
				var theCodFee=$('#aCodFee').text();
								
				$('.cancelProduct').each(function(){
					cancelProduct=$(this).attr('value').split('_');
					
					if($(this).attr('checked')){
					
						//合计金额
						theTotalPrice=theTotalPrice-parseFloat(cancelProduct[1]).toFixed(1)-parseFloat(cancelProduct[2]).toFixed(1)-parseFloat(cancelProduct[3]).toFixed(1);
						theDiscount=theDiscount-parseFloat(cancelProduct[2]).toFixed(1);
						//alert('theDiscount:'+theDiscount);
						theCoupon=theCoupon-parseFloat(cancelProduct[3]).toFixed(1);
						
					}else{
						weightSum+=parseFloat(cancelProduct[4]);
					}
				});
				
				var theNewShipfare=parseFloat($('#newShipfare').attr('value')).toFixed(1);
				
				//
				calBonusAndShipfare(theTotalPrice, theDiscount, theCoupon, theCodFee, weightSum);
				//
				
			});
		});
		
		if($('#dialog').length==0){
			$('body').append('<div id="dialog"></div>');
		}
	//更新狀態
		$(":input[id*=updOrdSt]").click(function(){
			var orderId = $(this).attr('id').split('_')[1];
			var orderStCode = $(this).attr('id').split('_')[2];
			if(orderStCode=='20'){
				if(!confirm('确定配货？'))return;
			}else{
				if(!confirm('确定取消？'))return;
			}
			$.post("<%=application.getContextPath()%>/order/updOrdSt.do",{orderId:orderId,orderStCode:orderStCode},callback,"json");
			function callback(result){				
				if(result=='success'){
					alert("更新成功");
					//window.location.replace("<%=application.getContextPath()%>/order/query.do");
					window.location.reload();
				}else{
					alert("更新失敗");
				}
			}		
		});	
		$(":input[id*=sendSms]").click(function(){
			var orderId = $(this).attr('id').split('_')[1];
			var orderContact = $(this).attr('id').split('_')[2];
			
			var smsMsg = "尊敬的会员，您好！您的訂單編號："+orderId+"，為了確保配送品質因多次聯絡不到您，您的訂單將不成立，若有需要再麻煩請您重新訂購";
			if(orderContact==''){
				alert('不正确的手机号码');
				return;
			}

			if(!confirm('确定发送短信？\n'+smsMsg))return;
			doAR('<%=application.getContextPath()%>/sms/sendSms.do?orderId='+orderId+'&orderContact='+orderContact+'&smsMsg='+smsMsg, 'dialog');openDialog('订单 '+orderId+' 短信发送记录',null,800,400);
					
		});	
		
	});
  function openBankPayment() {
	  window.open("../bankPayment/queryByOrder.do?orderId=${order.orderId}", "bankPayment", "height=300, width=400,left=50, top=50, menubar=no, toolbar=no, location=yes, directories=no, status=yes,scrollbars=yes,resizable=yes");
  }
  function openThirdPayment() {
	  window.open("../thirdPartyPayment/queryByOrder.do?orderId=${order.orderId}", "bankPayment", "height=300, width=600,left=50, top=50, menubar=no, toolbar=no, location=yes, directories=no, status=yes,scrollbars=yes,resizable=yes");
	}

</script>

<h1>修改订单及运费</h1>
<font color="#ff3300">
<s:actionerror />
<s:actionmessage />
<s:fielderror />
</font>
<div class="f-link">
<c-rt:if test="${pu:substring(user.group.code, 0, 1)!='C'}"><a href="/ecadmin/order/search.do">回订单查询页</a></c-rt:if>
<c-rt:if test="${pu:substring(user.group.code, 0, 1)=='C'}"><a href="/ecadmin/crmQuery/search.do">回CRM 查询</a></c-rt:if>
</div>
<br><table width="100%" border="1" cellspacing="0" cellpadding="0" class="tb-data">
  <tr>
    <td height="30" align=left><b>订单编号：</b> ${order.orderId}<br/>
    <c-rt:if test="${order.orderSt=='80' || order.orgOrderId!=null}">
    	<c-rt:if test="${order.orderSt=='80'}">
    	
    		${pu:reqSet('hqlMFK', 'from Orders where orgOrderId=?') }
    		${pu:listAdd('orderFKParams', order.orderId) }
    		${pu:reqSet('theOrdersFK', pu:queryByHql(hqlMFK, pu:arrayGet('orderFKParams'), null)) }
    		<c-rt:if test="${theOrdersFK !=null}">
    		(新成立订单：<a href="/ecadmin/order/view.do?orderId=${theOrdersFK[0].orderId }" target="_blank">${theOrdersFK[0].orderId }</a>)<br/>
    		</c-rt:if>
    	</c-rt:if>
    	<c-rt:if test="${order.orgOrderId!=null}">
    		(原订单：<a href="/ecadmin/order/view.do?orderId=${order.orgOrderId }" target="_blank">${order.orgOrderId }</a>)<br/>
    	</c-rt:if>
    
    </c-rt:if>
    
    <b>会员编号：</b>${order.memberId } </td>
    <td align=left><b>订购人：</b><a href='../member/view.do?memberId=${order.memberId}'>${order.memberName}</a></td>
    <td align=left><b>订单状态：
    	<c:if test="${empty cancelServiceOrders}">${orderStMenu.options[order.orderSt].name}</c:if>
    	<c:if test="${!empty cancelServiceOrders}">
    	<a href="<c-rt:url value="/serviceOrder/page.do?iamlazy=detail&from=list&serviceId=${cancelServiceOrders[0].serviceId}"/>">${orderStMenu.options[order.orderSt].name}</a>
    	</c:if></b>
    				<c-rt:if test="${order.orderSt=='00'}"><br/>
						<input name="按鈕" type="button" value="审核失敗" id="updOrdSt_${order.orderId}_82"/>
						<input name="按鈕" type="button" value="等待配貨" id="updOrdSt_${order.orderId}_20"/>
					</c-rt:if>
					<c-rt:if test="${order.paymentTp=='30'&&order.orderSt=='00'}">
						<br><input name="按鈕" type="button" value="联络不到简讯通知" id="sendSms_${order.orderId}_${fn:trim(order.receiverMobile)}"/>
					</c-rt:if>
					
					<c-rt:if test="${order.orderSt=='80' || order.orderSt=='81'}">
						<br/>取消时间：<fmt-rt:formatDate value="${order.modifyDate}" pattern="yyyy-MM-dd HH:mm"/>
					</c-rt:if>
    </td>
    <td align=left><b>订购日期：</b><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.orderDt}" /></td>
  </tr>
  <tr>
    <td height="30" align=left><b>付款方式：</b>${paymentTpMenu.options[order.paymentTp].name} (<a href="<c:url value="/order/viewChangeLog.do?orderId=${order.orderId}&logTp=chgPaymentTp"/>" >查看历程</a>)</td>
    <td align=left><b>付款状态：</b>${paymentStMenu.options[order.paymentSt].name}</td>
    <td align=left><b>订单来源：</b>${order.channel}<br><b>网站：</b>${domainSrc.options[order.domainSrc].name}</td>
    <td align=left><b>付款期限：</b><font color="#ff3300">
   	<c-rt:if test="${order.paymentTp!='30'}">
    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.deadline}" />
    </c-rt:if>
    </font></td>
  </tr>
  <tr>
    <td height="30" align=left><b>收件人：${order.receiverName} (<a href="<c:url value="/order/viewChangeLog.do?orderId=${order.orderId}&logTp=chgRecvInfo"/>" >查看历程</a>)</td>
    <td colspan="${order.receiverTp=='30'?2:3 }" align=left>行動：${order.receiverMobile}<br />
    固定：${order.receiverPhoneArea}-${order.receiverPhone}-${order.receiverExt}<br />
    地址：(${order.receiverZip})${order.receiverProvince}${order.receiverCity}${order.receiverArea}${order.receiverAddr}
    <c:if test="${order.receiverTp=='30'}"><a href="<c:url value="/dpn/queryStore.do?dpnStoreId=${order.storeId} "/>" target="_blank">店点资讯</a>   
	<img src="/images/daphne/daphne.gif"></c:if>
    </td>
    <c:if test="${order.receiverTp=='30'}">
    <td>    
	运送方式:達芙妮到店取貨<br />
	到店日期: <c-rt:if test="${!empty order.logisticFinalDt}"><fmt-rt:formatDate value="${order.logisticFinalDt }" pattern="yyyy-MM-dd HH:mm:ss"/></c-rt:if>
          <c-rt:if test="${empty order.logisticFinalDt }">--</c-rt:if> <br />
	签收日期: <c-rt:if test="${!empty order.logisticSignDt}"><fmt-rt:formatDate value="${order.logisticSignDt }" pattern="yyyy-MM-dd HH:mm:ss"/></c-rt:if>
          <c-rt:if test="${empty order.logisticSignDt }">--</c-rt:if> <br />
	</td>
    
	</c:if>
	
  </tr>
  <tr>
    <td height="30" align=left><b>訂單類型：${order.orderType==1?'一般':'SCM'}</td>
    <td colspan="3" align=left>轉單供應商：${supplierApply.companyName}</td>
  </tr>
  <tr>
    <td height="30" colspan="5" valign="top" align=left><b>备注</b><BR>
　　<textarea name=memo cols="70" rows="5">${order.memo}</textarea></td>
  </tr>
<c:if test="${order.campaign}">
  <tr height="30">
    <td colspan="5" align=left>活动：</td>
  </tr>
</c:if>
</table>
<b><BR />
訂單重量
</b><BR />
<table width="100%" class="tb-data" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><b>訂單重量：</b><fmt-rt:formatNumber value="${(order.totalWeight+0.001)/1000 }"  pattern="#,#0.00#"/>KG</td>
  </tr>
</table>
<b><br /> 
<b>付款资讯</b><br />
<table width="100%" class="tb-data" border="1" cellpadding="0" cellspacing="0">
  <tr class="bg-yl">
    <td height="30" align="left" colspan="2">付款日期：<b><font color="#ff3300"><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.paymentDt}" /></font></b></td>
    <td height="30" align="left" colspan="3">已付金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.cash}" pattern="#####0.0"/></font></b></td>
  </tr>
  <tr class="bg-yl">
	  <td height="30" align="left">已退金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.returnCash}" pattern="#####0.0"/></font></b></td>
    <td height="30" align="left">已退积分：<c-rt:if test = "${not empty order.orderBonusCampaign}">${order.returnBonus*order.orderBonusCampaign.offsetRate}</c-rt:if><c-rt:if test = "${empty order.orderBonusCampaign}">0</c-rt:if></td>
    <td align="left">已退我的帐户：<fmt:formatNumber value="${order.returnMyWallet}" pattern="#####0.0"/></td>
    <td align="left">已退我的礼品卡：<fmt:formatNumber value="${order.returnGiftcardBalance}" pattern="#####0.0"/></td>
    <td align="left">退款日期：<c-rt:if test="${order.returnCash!=0 || order.returnBonus!=0 || order.returnMyWallet!=0 || order.returnGiftcardBalance!=0}"><fmt:formatDate value="${order.modifyDate }" pattern="yyyy-MM-dd"/></c-rt:if></td>
  </tr>
</table>
<br /> 
<B>订购内容</B>
<br/>
<form name="orderForm" id="orderForm" method="POST" action="/ecadmin/crmUpdateOrder/updateOrderAndShipfare.do">
<input type="hidden" name="orderId" value="${order.orderId}">
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="tb-1">
	<thead>
	<tr>
	 <th>商品编号</th>
   <th height="30">商品</th>
    <th>重量</th>
    <th>数量</th>
    <th>单价</th>
    <th>coupon</th>
    <th>小计</th>
    <th>合计</th>
    <th>取消订购</th>
	</tr>
	</thead>
	<c:forEach items="${order.orderProduct}" var="oproduct">
		${pu:reqSet('productWeight', 0) }
		<c:forEach items="${oproduct.orderProductDetail}" var="opdetail">
			<c:set var="productWeight" value="${productWeight+opdetail.unitWeight*opdetail.qty}" scope="request"/>
		</c:forEach>

		${pu:listAdd('weightList', productWeight) }
	</c:forEach>
<c:forEach items="${order.orderProduct}" var="oproduct" varStatus="row_index">
<c:if test="${oproduct.prodTp!='2'}">
  <tr class="${row_index.count % 2 == 0 ? 'bg-yl' : ''}"><!-- 主商品 -->
  	<td> ${oproduct.prodId}<a href="<%=ServerValue.getFrontHostname()%><%=ServerValue.getFrontContextPath()%>/product/product.do?productId=${oproduct.prodId}" target="blank">开启</a><br>
  	<c-rt:if test="${fn:contains(snapShots,oproduct.prodId)}">
  	<a href="<c-rt:url value="/resource/${order.orderId}_${oproduct.prodId}_${oproduct.prodTp}.jpg?memberId=${order.memberId}"/>" target="blank">商品快照</a>
  	</c-rt:if>
  	</td>
    <td height="30" style="text-align:left;">
<span class="type-${oproduct.prodTp}">${detailTpMenu.options[oproduct.prodTp].name}</span> ${oproduct.prodName}<c:if test="${oproduct.prodTp!=6}">－<b>[${oproduct.prodSpecName}]</b></c:if>

<br/>


<br/>

<%try{ %>

<c-rt:forEach items="${oproduct.applyCampaigns}" var="ac">
	          	
	          	<p>
	          	<c-rt:if test="${ac.active}">
	          		<span class="type-4" style="color:red">优惠</span>
	          	</c-rt:if>
	          	<c-rt:if test="${!ac.active}">
	          		<span class="type-6"  style="color:gray">优惠</span>（不符合）
	          	</c-rt:if>
	          <c-rt:if test="${ac.campaignUrl!=null}">
	          	<a target="_blank" class="a-red" href="${ac.campaignUrl }">${ac.campaignName }</a>
	          	</c-rt:if>
	          	<c-rt:if test="${ac.campaignUrl==null}">
	          	
	          	${pu:reqSet('pc', pu:get('com.yaodian100.ec.campaign.entity.Campaign', ac.campaignUuid)) }
	          	
	          	${ac.campaignName }
	          	
	          	</c-rt:if>
	          	</p>
	          	</c-rt:forEach>

<%}catch(Exception e){
    e.printStackTrace();
    
    }%>

    </td>
    <td>
	    <c:forEach items="${oproduct.orderProductDetail}" var="opdetail" varStatus="rowdetail_index">
			<c:if test="${oproduct.prodSeq == opdetail.prodSeq }">
				<c:if test="${opdetail.detailTp == '0' || opdetail.detailTp == '1' || opdetail.detailTp == '5' || (opdetail.detailTp == '6' && opdetail.prodId == oproduct.prodId)}">
		    		<fmt-rt:formatNumber value="${(opdetail.unitWeight+0.001)/1000}"  pattern="#,#0.00#"/>
		    	 </c:if>
		    </c:if>
		</c:forEach>
    </td>
    <td>${oproduct.qty}</td>
    <td><fmt:formatNumber value="${oproduct.unitPrice}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.coupon}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.unitPrice*oproduct.qty}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.totalPrice}" pattern="#,###,##0.0"/></td>
  	<td>
  	<input type="checkbox" class="cancelProduct" name="cancelProduct" value="${oproduct.orderProdId }_${oproduct.amount}_${oproduct.discount}_${oproduct.coupon}_${weightList[row_index.index]}_${oproduct.prodId}"/>
  	
  	</td></tr>
  </c:if>
  <c:forEach items="${oproduct.orderProductDetail}" var="opdetail" varStatus="rowdetail_index">
<c:if test="${oproduct.prodSeq == opdetail.prodSeq }">
<c:if test="${opdetail.detailTp != '0' && opdetail.detailTp != '1' && opdetail.detailTp != '5' && !(opdetail.detailTp == '6' && opdetail.prodId == oproduct.prodId)}">
  <tr class="${row_index.count % 2 == 0 ? 'bg-yl' : ''}"><!-- 明细 -->
  <td><a href="<%=ServerValue.getFrontHostname()%><%=ServerValue.getFrontContextPath()%>/product/product.do?productId=${opdetail.prodId}" target="blank"> ${opdetail.prodId}</a>
  <br><c-rt:if test="${fn:contains(snapShots,opdetail.prodId)}">
  	<a href="<c-rt:url value="/resource/${order.orderId}_${opdetail.prodId}_${opdetail.detailTp}.jpg?memberId=${order.memberId}"/>" target="blank">商品快照</a>
  	</c-rt:if>
  </td>
    <td height="30" style="text-align:left;">
<span class="type-${opdetail.detailTp}">${detailTpMenu.options[opdetail.detailTp].name}</span> ${opdetail.prodName}－<b>[${opdetail.prodSpecName}]</b>
<c-rt:if test="${order.orderSt=='35' && oproduct.prodStatus!='1' && oproduct.prodStatus!='2'&& oproduct.prodTp=='2'}">
[ <a href="/ecadmin/serviceOrder/toReturnProduct.do?orderProdId=${oproduct.orderProdId }">退货</a> ｜ <a href="/ecadmin/serviceOrder/toChangeProduct.do?orderProdId=${oproduct.orderProdId }">换货</a> ]
</c-rt:if>
    </td>
    <td><fmt-rt:formatNumber value="${(opdetail.unitWeight+0.001)/1000}"  pattern="#,#0.00#"/></td>
    <td>${opdetail.qty}</td>    
    <td><fmt:formatNumber value="${opdetail.unitPrice}" pattern="#,###,##0.0"/></td>
    <td>--</td>
    <td><fmt:formatNumber value="${opdetail.amount}" pattern="#,###,##0.0"/></td>
    <td>--</td>
    <td></td>
  </tr>
  
</c:if>
 
</c:if>


</c:forEach>
</c:forEach>
</table>
<table width="100%">
<tr>
<td width="50%" valign="top">
<table width="100%">
<tr class="tb-R bg-yl">
	<th height="30" colspan="13">原订单</th>
</tr>
	<tr class="tb-R bg-yl">
    <td height="30" colspan="13">商品总额：<fmt:formatNumber value="${order.totalPrice}" pattern="#,###,##0.0"/></td>
  </tr>
	<tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折抵优惠：<fmt:formatNumber value="${order.discount}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝合计金额：<fmt:formatNumber value="${order.amount}" pattern="#,###,##0.0"/></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＋运费：<fmt:formatNumber value="${order.shipfare}" pattern="#,###,##0.0"/>
    </td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＋货到付款手续费：<fmt:formatNumber value="${order.codFee}" pattern="#,###,##0.0"/></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折扣礼券：<fmt:formatNumber value="${order.coupon}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折抵 <c-rt:if test = "${not empty order.orderBonusCampaign}">${order.bonus*order.orderBonusCampaign.offsetRate}</c-rt:if><c-rt:if test = "${empty order.orderBonusCampaign}">0</c-rt:if> 积分：<fmt:formatNumber value="${order.bonus}" pattern="#,###,##0.0"/></td>
  </tr>

  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝订单金额：<fmt:formatNumber value="${order.totalPrice- order.bonus - order.coupon + order.shipfare - order.discount + order.codFee}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－礼品卡支付：<fmt:formatNumber value="${order.giftcardBalance}" pattern="#,###,##0.0"/></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－账户余额支付：<fmt:formatNumber value="${order.myWallet}" pattern="#,###,##0.0"/></td>
  </tr>
    <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝剩余应付金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.mustPay}" pattern="#,###,##0.0"/></font></b></td>
  </tr>
</table>
</td>

<td>
<table width="100%">
<tr class="tb-R bg-yl">
	<th height="30" colspan="13">修改后</th>
</tr>
<tr class="tb-R bg-yl">
    <td height="30" colspan="13">商品总额：<span id="aTotalPrice"><fmt:formatNumber value="${order.totalPrice}" pattern="#,###,##0.0"/></span></td>
  </tr>
 <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折抵优惠：<span id="aDiscount"><fmt:formatNumber value="${order.discount}" pattern="#,###,##0.0"/></span></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝合计金额：<span id="aAmount"><fmt:formatNumber value="${order.amount}" pattern="#,###,##0.0"/></span></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">
    <div id="editShipFare">
    <a name="editShipFareHere"> </a>
    ＋运费：<input type="text"  class="txt-gy" name="newShipfare" id="newShipfare" value="<fmt:formatNumber value="${order.shipfare}" pattern="#,###,##0.0"/>" maxlength="5" size="5"/>

    </div>
    </td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＋货到付款手续费：<span id="aCodFee"><fmt:formatNumber value="${order.codFee}" pattern="#,###,##0.0"/></span></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折扣礼券：<span id="aCoupon"><fmt:formatNumber value="${order.coupon}" pattern="#,###,##0.0"/></span></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折抵<span id="aBonusDiscount"> <c-rt:if test = "${not empty order.orderBonusCampaign}">${order.bonus*order.orderBonusCampaign.offsetRate}</c-rt:if></span><c-rt:if test = "${empty order.orderBonusCampaign}">0</c-rt:if> 积分：<span id="aBonus"><fmt:formatNumber value="${order.bonus}" pattern="#,###,##0.0"/></span></td>
  </tr>

  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝订单金额：<span id="aTotalOrderPrice"><fmt:formatNumber value="${order.totalPrice- order.bonus - order.coupon + order.shipfare - order.discount + order.codFee}" pattern="#,###,##0.0"/></span></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－礼品卡支付：<span id="aGiftcardBalance"><fmt:formatNumber value="${order.giftcardBalance}" pattern="#,###,##0.0"/></span></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－账户余额支付：<span id="aMyWallet"><fmt:formatNumber value="${order.myWallet}" pattern="#,###,##0.0"/></span></td>
  </tr>
    <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝剩余应付金额：<b><font color="#ff3300"><span id="aMustPay"><fmt:formatNumber value="${order.mustPay}" pattern="#,###,##0.0"/></span></font></b></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝应退金额：<b><font color="#ff3300"><span id="aMustReturn">0</span></font></b></td>
  </tr>
</table>
</td>
</tr>

</table>
</form>
<div class="f-link">
	<c-rt:if test="${not empty pop}"><a href="javascript:window.close()">关闭视窗</a> / </c-rt:if><c-rt:if test="${pu:substring(user.group.code, 0, 1)!='C'}"><a href="/ecadmin/order/search.do">回订单查询页</a></c-rt:if><c-rt:if test="${pu:substring(user.group.code, 0, 1)=='C'}"><a href="/ecadmin/crmQuery/search.do">回CRM 查询</a></c-rt:if><a href="javascript:void(0);" id="submitForm">送出表单</a>
</div>
</c-rt:if>